<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Logger - logger: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-Logger-label-About+the+Examples">About the Examples</a>
    <li><a href="#class-Logger-label-Synopsis">Synopsis</a>
    <li><a href="#class-Logger-label-Entries">Entries</a>
    <li><a href="#class-Logger-label-Severity">Severity</a>
    <li><a href="#class-Logger-label-Timestamp">Timestamp</a>
    <li><a href="#class-Logger-label-Message">Message</a>
    <li><a href="#class-Logger-label-Program+Name">Program Name</a>
    <li><a href="#class-Logger-label-Log+Level">Log Level</a>
    <li><a href="#class-Logger-label-Log+File+Rotation">Log File Rotation</a>
    <li><a href="#class-Logger-label-Size-Based+Rotation">Size-Based Rotation</a>
    <li><a href="#class-Logger-label-Periodic+Rotation">Periodic Rotation</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="Logger/Severity.html">Logger::Severity</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-3C-3C">#&lt;&lt;</a>
    <li ><a href="#method-i-add">#add</a>
    <li ><a href="#method-i-close">#close</a>
    <li ><a href="#method-i-datetime_format">#datetime_format</a>
    <li ><a href="#method-i-datetime_format-3D">#datetime_format=</a>
    <li ><a href="#method-i-debug">#debug</a>
    <li ><a href="#method-i-debug-21">#debug!</a>
    <li ><a href="#method-i-debug-3F">#debug?</a>
    <li ><a href="#method-i-error">#error</a>
    <li ><a href="#method-i-error-21">#error!</a>
    <li ><a href="#method-i-error-3F">#error?</a>
    <li ><a href="#method-i-fatal">#fatal</a>
    <li ><a href="#method-i-fatal-21">#fatal!</a>
    <li ><a href="#method-i-fatal-3F">#fatal?</a>
    <li ><a href="#method-i-format_message">#format_message</a>
    <li ><a href="#method-i-format_severity">#format_severity</a>
    <li ><a href="#method-i-info">#info</a>
    <li ><a href="#method-i-info-21">#info!</a>
    <li ><a href="#method-i-info-3F">#info?</a>
    <li ><a href="#method-i-level">#level</a>
    <li ><a href="#method-i-level-3D">#level=</a>
    <li ><a href="#method-i-log">#log</a>
    <li ><a href="#method-i-reopen">#reopen</a>
    <li ><a href="#method-i-sev_threshold">#sev_threshold</a>
    <li ><a href="#method-i-sev_threshold-3D">#sev_threshold=</a>
    <li ><a href="#method-i-unknown">#unknown</a>
    <li ><a href="#method-i-warn">#warn</a>
    <li ><a href="#method-i-warn-21">#warn!</a>
    <li ><a href="#method-i-warn-3F">#warn?</a>
    <li ><a href="#method-i-with_level">#with_level</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Logger">
    <h1 id="class-Logger" class="class">
      class Logger
    </h1>

    <section class="description">
    
<p>Class Logger provides a simple but sophisticated logging utility that you can use to create one or more <a href="https://en.wikipedia.org/wiki/Logging_(software)#Event_logs">event logs</a> for your program. Each such log contains a chronological sequence of entries that provides a record of the program’s activities.</p>

<h2 id="class-Logger-label-About+the+Examples">About the Examples<span><a href="#class-Logger-label-About+the+Examples">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>All examples on this page assume that Logger has been required:</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;logger&#39;</span>
</pre>

<h2 id="class-Logger-label-Synopsis">Synopsis<span><a href="#class-Logger-label-Synopsis">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Create a log with <a href="Logger.html#method-c-new"><code>Logger.new</code></a>:</p>

<pre class="ruby"><span class="ruby-comment"># Single log file.</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>)
<span class="ruby-comment"># Size-based rotated logging: 3 10-megabyte files.</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">3</span>, <span class="ruby-value">10485760</span>)
<span class="ruby-comment"># Period-based rotated logging: daily (also allowed: &#39;weekly&#39;, &#39;monthly&#39;).</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-string">&#39;daily&#39;</span>)
<span class="ruby-comment"># Log to an IO stream.</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
</pre>

<p>Add entries (level, message) with <a href="Logger.html#method-i-add"><code>Logger#add</code></a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-string">&#39;Maximal debugging info&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&#39;Non-error information&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>, <span class="ruby-string">&#39;Non-error warning&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;Non-fatal error&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">FATAL</span>, <span class="ruby-string">&#39;Fatal error&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">UNKNOWN</span>, <span class="ruby-string">&#39;Most severe&#39;</span>)
</pre>

<p>Close the log with <a href="Logger.html#method-i-close"><code>Logger#close</code></a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">close</span>
</pre>

<h2 id="class-Logger-label-Entries">Entries<span><a href="#class-Logger-label-Entries">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>You can add entries with method <a href="Logger.html#method-i-add"><code>Logger#add</code></a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-string">&#39;Maximal debugging info&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&#39;Non-error information&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>, <span class="ruby-string">&#39;Non-error warning&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;Non-fatal error&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">FATAL</span>, <span class="ruby-string">&#39;Fatal error&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">UNKNOWN</span>, <span class="ruby-string">&#39;Most severe&#39;</span>)
</pre>

<p>These shorthand methods also add entries:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-string">&#39;Maximal debugging info&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-string">&#39;Non-error information&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn</span>(<span class="ruby-string">&#39;Non-error warning&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-string">&#39;Non-fatal error&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">fatal</span>(<span class="ruby-string">&#39;Fatal error&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">unknown</span>(<span class="ruby-string">&#39;Most severe&#39;</span>)
</pre>

<p>When you call any of these methods, the entry may or may not be written to the log, depending on the entry’s severity and on the log level; see <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a></p>

<p>An entry always has:</p>
<ul><li>
<p>A severity (the required argument to <a href="Logger.html#method-i-add"><code>add</code></a>).</p>
</li><li>
<p>An automatically created timestamp.</p>
</li></ul>

<p>And may also have:</p>
<ul><li>
<p>A message.</p>
</li><li>
<p>A program name.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&#39;My message.&#39;</span>, <span class="ruby-string">&#39;mung&#39;</span>)
<span class="ruby-comment"># =&gt; I, [2022-05-07T17:21:46.536234 #20536]  INFO -- mung: My message.</span>
</pre>

<p>The default format for an entry is:</p>

<pre class="ruby"><span class="ruby-string">&quot;%s, [%s #%d] %5s -- %s: %s\n&quot;</span>
</pre>

<p>where the values to be formatted are:</p>
<ul><li>
<p>Severity (one letter).</p>
</li><li>
<p>Timestamp.</p>
</li><li>
<p>Process id.</p>
</li><li>
<p>Severity (word).</p>
</li><li>
<p>Program name.</p>
</li><li>
<p>Message.</p>
</li></ul>

<p>You can use a different entry format by:</p>
<ul><li>
<p>Setting a custom format proc (affects following entries); see <a href="Logger.html#attribute-i-formatter">formatter=</a>.</p>
</li><li>
<p>Calling any of the methods above with a block (affects only the one entry). Doing so can have two benefits:</p>
<ul><li>
<p>Context: the block can evaluate the entire program context and create a context-dependent message.</p>
</li><li>
<p>Performance: the block is not evaluated unless the log level permits the entry actually to be written:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> { <span class="ruby-identifier">my_slow_message_generator</span> }
</pre>

<p>Contrast this with the string form, where the string is always evaluated, regardless of the log level:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;#{my_slow_message_generator}&quot;</span>)
</pre>
</li></ul>
</li></ul>

<h3 id="class-Logger-label-Severity">Severity<span><a href="#class-Logger-label-Severity">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The severity of a log entry has two effects:</p>
<ul><li>
<p>Determines whether the entry is selected for inclusion in the log; see <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>
</li><li>
<p>Indicates to any log reader (whether a person or a program) the relative importance of the entry.</p>
</li></ul>

<h3 id="class-Logger-label-Timestamp">Timestamp<span><a href="#class-Logger-label-Timestamp">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The timestamp for a log entry is generated automatically when the entry is created.</p>

<p>The logged timestamp is formatted by method Time#strftime using this format string:</p>

<pre class="ruby"><span class="ruby-string">&#39;%Y-%m-%dT%H:%M:%S.%6N&#39;</span>
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>)
<span class="ruby-comment"># =&gt; I, [2022-05-07T17:04:32.318331 #20536]  INFO -- : nil</span>
</pre>

<p>You can set a different format using method <a href="Logger.html#method-i-datetime_format-3D"><code>datetime_format=</code></a>.</p>

<h3 id="class-Logger-label-Message">Message<span><a href="#class-Logger-label-Message">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The message is an optional argument to an entry method:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&#39;My message&#39;</span>)
<span class="ruby-comment"># =&gt; I, [2022-05-07T18:15:37.647581 #20536]  INFO -- : My message</span>
</pre>

<p>For the default entry formatter, <code>Logger::Formatter</code>, the message object may be:</p>
<ul><li>
<p>A string: used as-is.</p>
</li><li>
<p>An Exception: <code>message.message</code> is used.</p>
</li><li>
<p>Anything else: <code>message.inspect</code> is used.</p>
</li></ul>

<p><strong>Note</strong>: <a href="Logger/Formatter.html"><code>Logger::Formatter</code></a> does not escape or sanitize the message passed to it. Developers should be aware that malicious data (user input) may be in the message, and should explicitly escape untrusted data.</p>

<p>You can use a custom formatter to escape message data; see the example at <a href="Logger.html#attribute-i-formatter">formatter=</a>.</p>

<h3 id="class-Logger-label-Program+Name">Program Name<span><a href="#class-Logger-label-Program+Name">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The program name is an optional argument to an entry method:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&#39;My message&#39;</span>, <span class="ruby-string">&#39;mung&#39;</span>)
<span class="ruby-comment"># =&gt; I, [2022-05-07T18:17:38.084716 #20536]  INFO -- mung: My message</span>
</pre>

<p>The default program name for a new logger may be set in the call to <a href="Logger.html#method-c-new"><code>Logger.new</code></a> via optional keyword argument <code>progname</code>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">progname:</span> <span class="ruby-string">&#39;mung&#39;</span>)
</pre>

<p>The default program name for an existing logger may be set by a call to method <a href="Logger.html#attribute-i-progname"><code>progname=</code></a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">progname</span> = <span class="ruby-string">&#39;mung&#39;</span>
</pre>

<p>The current program name may be retrieved with method <a href="Logger.html#attribute-i-progname">progname</a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">progname</span> <span class="ruby-comment"># =&gt; &quot;mung&quot;</span>
</pre>

<h2 id="class-Logger-label-Log+Level">Log Level<span><a href="#class-Logger-label-Log+Level">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>The log level setting determines whether an entry is actually written to the log, based on the entry’s severity.</p>

<p>These are the defined severities (least severe to most severe):</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">DEBUG</span>, <span class="ruby-string">&#39;Maximal debugging info&#39;</span>)
<span class="ruby-comment"># =&gt; D, [2022-05-07T17:57:41.776220 #20536] DEBUG -- : Maximal debugging info</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&#39;Non-error information&#39;</span>)
<span class="ruby-comment"># =&gt; I, [2022-05-07T17:59:14.349167 #20536]  INFO -- : Non-error information</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>, <span class="ruby-string">&#39;Non-error warning&#39;</span>)
<span class="ruby-comment"># =&gt; W, [2022-05-07T18:00:45.337538 #20536]  WARN -- : Non-error warning</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;Non-fatal error&#39;</span>)
<span class="ruby-comment"># =&gt; E, [2022-05-07T18:02:41.592912 #20536] ERROR -- : Non-fatal error</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">FATAL</span>, <span class="ruby-string">&#39;Fatal error&#39;</span>)
<span class="ruby-comment"># =&gt; F, [2022-05-07T18:05:24.703931 #20536] FATAL -- : Fatal error</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">UNKNOWN</span>, <span class="ruby-string">&#39;Most severe&#39;</span>)
<span class="ruby-comment"># =&gt; A, [2022-05-07T18:07:54.657491 #20536]   ANY -- : Most severe</span>
</pre>

<p>The default initial level setting is Logger::DEBUG, the lowest level, which means that all entries are to be written, regardless of severity:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">0</span>, <span class="ruby-string">&quot;My message&quot;</span>)
<span class="ruby-comment"># =&gt; D, [2022-05-11T15:10:59.773668 #20536] DEBUG -- : My message</span>
</pre>

<p>You can specify a different setting in a new logger using keyword argument <code>level</code> with an appropriate value:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>, <span class="ruby-value">level:</span> <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>)
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>, <span class="ruby-value">level:</span> <span class="ruby-string">&#39;error&#39;</span>)
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>, <span class="ruby-value">level:</span> <span class="ruby-value">:error</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> <span class="ruby-comment"># =&gt; 3</span>
</pre>

<p>With this level, entries with severity Logger::ERROR and higher are written, while those with lower severities are not written:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>, <span class="ruby-value">level:</span> <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">3</span>)
<span class="ruby-comment"># =&gt; E, [2022-05-11T15:17:20.933362 #20536] ERROR -- : nil</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-value">2</span>) <span class="ruby-comment"># Silent.</span>
</pre>

<p>You can set the log level for an existing logger with method <a href="Logger.html#method-i-level-3D"><code>level=</code></a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>
</pre>

<p>These shorthand methods also set the level:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug!</span> <span class="ruby-comment"># =&gt; 0</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info!</span>  <span class="ruby-comment"># =&gt; 1</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn!</span>  <span class="ruby-comment"># =&gt; 2</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error!</span> <span class="ruby-comment"># =&gt; 3</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">fatal!</span> <span class="ruby-comment"># =&gt; 4</span>
</pre>

<p>You can retrieve the log level with method <a href="Logger.html#attribute-i-level">level</a>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> <span class="ruby-comment"># =&gt; 3</span>
</pre>

<p>These methods return whether a given level is to be written:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug?</span> <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info?</span>  <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">warn?</span>  <span class="ruby-comment"># =&gt; false</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error?</span> <span class="ruby-comment"># =&gt; true</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">fatal?</span> <span class="ruby-comment"># =&gt; true</span>
</pre>

<h2 id="class-Logger-label-Log+File+Rotation">Log File Rotation<span><a href="#class-Logger-label-Log+File+Rotation">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>By default, a log file is a single file that grows indefinitely (until explicitly closed); there is no file rotation.</p>

<p>To keep log files to a manageable size, you can use <em>log</em> <em>file</em> <em>rotation</em>, which uses multiple log files:</p>
<ul><li>
<p>Each log file has entries for a non-overlapping time interval.</p>
</li><li>
<p>Only the most recent log file is open and active; the others are closed and inactive.</p>
</li></ul>

<h3 id="class-Logger-label-Size-Based+Rotation">Size-Based Rotation<span><a href="#class-Logger-label-Size-Based+Rotation">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>For size-based log file rotation, call <a href="Logger.html#method-c-new"><code>Logger.new</code></a> with:</p>
<ul><li>
<p>Argument <code>logdev</code> as a file path.</p>
</li><li>
<p>Argument <code>shift_age</code> with a positive integer: the number of log files to be in the rotation.</p>
</li><li>
<p>Argument <code>shift_size</code> as a positive integer: the maximum size (in bytes) of each log file; defaults to 1048576 (1 megabyte).</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">3</span>)           <span class="ruby-comment"># Three 1-megabyte files.</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">5</span>, <span class="ruby-value">10485760</span>) <span class="ruby-comment"># Five 10-megabyte files.</span>
</pre>

<p>For these examples, suppose:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">3</span>)
</pre>

<p>Logging begins in the new log file, <code>t.log</code>; the log file is “full” and ready for rotation when a new entry would cause its size to exceed <code>shift_size</code>.</p>

<p>The first time <code>t.log</code> is full:</p>
<ul><li>
<p><code>t.log</code> is closed and renamed to <code>t.log.0</code>.</p>
</li><li>
<p>A new file <code>t.log</code> is opened.</p>
</li></ul>

<p>The second time <code>t.log</code> is full:</p>
<ul><li>
<p>+t.log.0 is renamed as <code>t.log.1</code>.</p>
</li><li>
<p><code>t.log</code> is closed and renamed to <code>t.log.0</code>.</p>
</li><li>
<p>A new file <code>t.log</code> is opened.</p>
</li></ul>

<p>Each subsequent time that <code>t.log</code> is full, the log files are rotated:</p>
<ul><li>
<p><code>t.log.1</code> is removed.</p>
</li><li>
<p>+t.log.0 is renamed as <code>t.log.1</code>.</p>
</li><li>
<p><code>t.log</code> is closed and renamed to <code>t.log.0</code>.</p>
</li><li>
<p>A new file <code>t.log</code> is opened.</p>
</li></ul>

<h3 id="class-Logger-label-Periodic+Rotation">Periodic Rotation<span><a href="#class-Logger-label-Periodic+Rotation">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>For periodic rotation, call <a href="Logger.html#method-c-new"><code>Logger.new</code></a> with:</p>
<ul><li>
<p>Argument <code>logdev</code> as a file path.</p>
</li><li>
<p>Argument <code>shift_age</code> as a string period indicator.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-string">&#39;daily&#39;</span>)   <span class="ruby-comment"># Rotate log files daily.</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-string">&#39;weekly&#39;</span>)  <span class="ruby-comment"># Rotate log files weekly.</span>
<span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-string">&#39;monthly&#39;</span>) <span class="ruby-comment"># Rotate log files monthly.</span>
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-string">&#39;daily&#39;</span>)
</pre>

<p>When the given period expires:</p>
<ul><li>
<p>The base log file, <code>t.log</code> is closed and renamed with a date-based suffix such as <code>t.log.20220509</code>.</p>
</li><li>
<p>A new log file <code>t.log</code> is opened.</p>
</li><li>
<p>Nothing is removed.</p>
</li></ul>

<p>The default format for the suffix is <code>&#39;%Y%m%d&#39;</code>, which produces a suffix similar to the one above. You can set a different format using create-time option <code>shift_period_suffix</code>; see details and suggestions at Time#strftime.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="ProgName">ProgName
          <dd>
          <dt id="SEV_LABEL">SEV_LABEL
          <dd><p>Severity label for logging (max 5 chars).</p>
          <dt id="VERSION">VERSION
          <dd>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-formatter" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">formatter</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Sets or retrieves the logger entry formatter proc.</p>

<p>When <code>formatter</code> is <code>nil</code>, the logger uses <a href="Logger/Formatter.html"><code>Logger::Formatter</code></a>.</p>

<p>When <code>formatter</code> is a proc, a new entry is formatted by the proc, which is called with four arguments:</p>
<ul><li>
<p><code>severity</code>: The severity of the entry.</p>
</li><li>
<p><code>time</code>: A Time object representing the entry’s timestamp.</p>
</li><li>
<p><code>progname</code>: The program name for the entry.</p>
</li><li>
<p><code>msg</code>: The message for the entry (string or string-convertible object).</p>
</li></ul>

<p>The proc should return a string containing the formatted entry.</p>

<p>This custom formatter uses String#dump to escape the message string:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>, <span class="ruby-value">progname:</span> <span class="ruby-string">&#39;mung&#39;</span>)
<span class="ruby-identifier">original_formatter</span> = <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">formatter</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">Formatter</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">proc</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">severity</span>, <span class="ruby-identifier">time</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">msg</span><span class="ruby-operator">|</span>
  <span class="ruby-identifier">original_formatter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">severity</span>, <span class="ruby-identifier">time</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">dump</span>)
}
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&quot;hello \n &#39;&#39;&quot;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>, <span class="ruby-string">&quot;\f\x00\xff\\\&quot;&quot;</span>)
</pre>

<p>Output:</p>

<pre>I, [2022-05-13T13:16:29.637488 #8492]  INFO -- mung: &quot;hello \n &#39;&#39;&quot;
I, [2022-05-13T13:16:29.637610 #8492]  INFO -- mung: &quot;\f\x00\xFF\\\&quot;&quot;</pre>
              </div>
            </div>
          <div id="attribute-i-progname" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">progname</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Program name to include in log messages.</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(logdev, shift_age = 0, shift_size = 1048576, **options)
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>With the single argument <code>logdev</code>, returns a new logger with all default options:</p>

<pre class="ruby"><span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>) <span class="ruby-comment"># =&gt; #&lt;Logger:0x000001e685dc6ac8&gt;</span>
</pre>

<p>Argument <code>logdev</code> must be one of:</p>
<ul><li>
<p>A string filepath: entries are to be written to the file at that path; if the file at that path exists, new entries are appended.</p>
</li><li>
<p>An IO stream (typically +$stdout+, +$stderr+. or an open file): entries are to be written to the given stream.</p>
</li><li>
<p><code>nil</code> or <code>File::NULL</code>: no entries are to be written.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>)
<span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
</pre>

<p>The keyword options are:</p>
<ul><li>
<p><code>level</code>: sets the log level; default value is Logger::DEBUG. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>:</p>

<pre class="ruby"><span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">level:</span> <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>)
</pre>
</li><li>
<p><code>progname</code>: sets the default program name; default is <code>nil</code>. See <a href="Logger.html#class-Logger-label-Program+Name">Program Name</a>:</p>

<pre class="ruby"><span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>, <span class="ruby-value">progname:</span> <span class="ruby-string">&#39;mung&#39;</span>)
</pre>
</li><li>
<p><code>formatter</code>: sets the entry formatter; default is <code>nil</code>. See <a href="Logger.html#attribute-i-formatter">formatter=</a>.</p>
</li><li>
<p><code>datetime_format</code>: sets the format for entry timestamp; default is <code>nil</code>. See <a href="Logger.html#method-i-datetime_format-3D"><code>datetime_format=</code></a>.</p>
</li><li>
<p><code>binmode</code>: sets whether the logger writes in binary mode; default is <code>false</code>.</p>
</li><li>
<p><code>shift_period_suffix</code>: sets the format for the filename suffix for periodic log file rotation; default is <code>&#39;%Y%m%d&#39;</code>. See <a href="Logger.html#class-Logger-label-Periodic+Rotation">Periodic Rotation</a>.</p>
</li></ul>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File logger.rb, line 579</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">logdev</span>, <span class="ruby-identifier">shift_age</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">shift_size</span> = <span class="ruby-value">1048576</span>, <span class="ruby-value">level:</span> <span class="ruby-constant">DEBUG</span>,
               <span class="ruby-value">progname:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">formatter:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">datetime_format:</span> <span class="ruby-keyword">nil</span>,
               <span class="ruby-value">binmode:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">shift_period_suffix:</span> <span class="ruby-string">&#39;%Y%m%d&#39;</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">level</span> = <span class="ruby-identifier">level</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">progname</span> = <span class="ruby-identifier">progname</span>
  <span class="ruby-ivar">@default_formatter</span> = <span class="ruby-constant">Formatter</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">datetime_format</span> = <span class="ruby-identifier">datetime_format</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">formatter</span> = <span class="ruby-identifier">formatter</span>
  <span class="ruby-ivar">@logdev</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@level_override</span> = {}
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">logdev</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">logdev</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">NULL</span>
    <span class="ruby-ivar">@logdev</span> = <span class="ruby-constant">LogDevice</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">logdev</span>, <span class="ruby-value">shift_age:</span> <span class="ruby-identifier">shift_age</span>,
      <span class="ruby-value">shift_size:</span> <span class="ruby-identifier">shift_size</span>,
      <span class="ruby-value">shift_period_suffix:</span> <span class="ruby-identifier">shift_period_suffix</span>,
      <span class="ruby-value">binmode:</span> <span class="ruby-identifier">binmode</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3C-3C" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">&lt;&lt;</span><span
                                class="method-args">(msg)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Writes the given <code>msg</code> to the log with no formatting; returns the number of characters written, or <code>nil</code> if no log device exists:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>)
<span class="ruby-identifier">logger</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;My message.&#39;</span> <span class="ruby-comment"># =&gt; 10</span>
</pre>

<p>Output:</p>

<pre>My message.</pre>

                              <div class="method-source-code" id="3C-3C-source">
            <pre><span class="ruby-comment"># File logger.rb, line 685</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">&lt;&lt;</span>(<span class="ruby-identifier">msg</span>)
  <span class="ruby-ivar">@logdev</span>&amp;.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">msg</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-add" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">add</span><span
                                class="method-args">(severity, message = nil, progname = nil) { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a log entry, which may or may not be written to the log, depending on the entry’s severity and on the log level. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a> and <a href="Logger.html#class-Logger-label-Entries">Entries</a> for details.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">$stdout</span>, <span class="ruby-value">progname:</span> <span class="ruby-string">&#39;mung&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">INFO</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;No good&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;No good&#39;</span>, <span class="ruby-string">&#39;gnum&#39;</span>)
</pre>

<p>Output:</p>

<pre>I, [2022-05-12T16:25:31.469726 #36328]  INFO -- mung: mung
E, [2022-05-12T16:25:55.349414 #36328] ERROR -- mung: No good
E, [2022-05-12T16:26:35.841134 #36328] ERROR -- gnum: No good</pre>

<p>These convenience methods have implicit severity:</p>
<ul><li>
<p><a href="Logger.html#method-i-debug"><code>debug</code></a>.</p>
</li><li>
<p><a href="Logger.html#method-i-info"><code>info</code></a>.</p>
</li><li>
<p><a href="Logger.html#method-i-warn"><code>warn</code></a>.</p>
</li><li>
<p><a href="Logger.html#method-i-error"><code>error</code></a>.</p>
</li><li>
<p><a href="Logger.html#method-i-fatal"><code>fatal</code></a>.</p>
</li><li>
<p><a href="Logger.html#method-i-unknown"><code>unknown</code></a>.</p>
</li></ul>

                              <div class="method-source-code" id="add-source">
            <pre><span class="ruby-comment"># File logger.rb, line 652</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add</span>(<span class="ruby-identifier">severity</span>, <span class="ruby-identifier">message</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">severity</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">UNKNOWN</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@logdev</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">severity</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">level</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">progname</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">progname</span> = <span class="ruby-ivar">@progname</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">message</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
      <span class="ruby-identifier">message</span> = <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">message</span> = <span class="ruby-identifier">progname</span>
      <span class="ruby-identifier">progname</span> = <span class="ruby-ivar">@progname</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@logdev</span>.<span class="ruby-identifier">write</span>(
    <span class="ruby-identifier">format_message</span>(<span class="ruby-identifier">format_severity</span>(<span class="ruby-identifier">severity</span>), <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">message</span>))
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Logger.html#method-i-log">log</a>
                            </div>

                          </div>

                  <div id="method-i-close" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">close</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Closes the logger; returns <code>nil</code>:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">close</span>       <span class="ruby-comment"># =&gt; nil</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-string">&#39;foo&#39;</span>) <span class="ruby-comment"># Prints &quot;log writing failed. closed stream&quot;</span>
</pre>

<p>Related: <a href="Logger.html#method-i-reopen"><code>Logger#reopen</code></a>.</p>

                              <div class="method-source-code" id="close-source">
            <pre><span class="ruby-comment"># File logger.rb, line 732</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">close</span>
  <span class="ruby-ivar">@logdev</span>&amp;.<span class="ruby-identifier">close</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-datetime_format" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">datetime_format</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the date-time format; see <a href="Logger.html#method-i-datetime_format-3D"><code>datetime_format=</code></a>.</p>

                              <div class="method-source-code" id="datetime_format-source">
            <pre><span class="ruby-comment"># File logger.rb, line 439</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">datetime_format</span>
  <span class="ruby-ivar">@default_formatter</span>.<span class="ruby-identifier">datetime_format</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-datetime_format-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">datetime_format=</span><span
                                class="method-args">(datetime_format)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the date-time format.</p>

<p>Argument <code>datetime_format</code> should be either of these:</p>
<ul><li>
<p>A string suitable for use as a format for method Time#strftime.</p>
</li><li>
<p><code>nil</code>: the logger uses <code>&#39;%Y-%m-%dT%H:%M:%S.%6N&#39;</code>.</p>
</li></ul>

                              <div class="method-source-code" id="datetime_format-3D-source">
            <pre><span class="ruby-comment"># File logger.rb, line 433</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">datetime_format=</span>(<span class="ruby-identifier">datetime_format</span>)
  <span class="ruby-ivar">@default_formatter</span>.<span class="ruby-identifier">datetime_format</span> = <span class="ruby-identifier">datetime_format</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-debug" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug</span><span
                                class="method-args">(progname = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to calling <a href="Logger.html#method-i-add"><code>add</code></a> with severity <code>Logger::DEBUG</code>.</p>

                              <div class="method-source-code" id="debug-source">
            <pre><span class="ruby-comment"># File logger.rb, line 691</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug</span>(<span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">add</span>(<span class="ruby-constant">DEBUG</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-debug-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the log level to Logger::DEBUG. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="debug-21-source">
            <pre><span class="ruby-comment"># File logger.rb, line 488</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug!</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">DEBUG</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-debug-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">debug?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the log level allows entries with severity Logger::DEBUG to be written, <code>false</code> otherwise. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="debug-3F-source">
            <pre><span class="ruby-comment"># File logger.rb, line 483</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">debug?</span>; <span class="ruby-identifier">level</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">DEBUG</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-error" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">error</span><span
                                class="method-args">(progname = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to calling <a href="Logger.html#method-i-add"><code>add</code></a> with severity <code>Logger::ERROR</code>.</p>

                              <div class="method-source-code" id="error-source">
            <pre><span class="ruby-comment"># File logger.rb, line 709</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">error</span>(<span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">add</span>(<span class="ruby-constant">ERROR</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-error-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">error!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the log level to Logger::ERROR. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="error-21-source">
            <pre><span class="ruby-comment"># File logger.rb, line 521</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">error!</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">ERROR</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-error-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">error?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the log level allows entries with severity Logger::ERROR to be written, <code>false</code> otherwise. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="error-3F-source">
            <pre><span class="ruby-comment"># File logger.rb, line 516</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">error?</span>; <span class="ruby-identifier">level</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">ERROR</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fatal" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fatal</span><span
                                class="method-args">(progname = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to calling <a href="Logger.html#method-i-add"><code>add</code></a> with severity <code>Logger::FATAL</code>.</p>

                              <div class="method-source-code" id="fatal-source">
            <pre><span class="ruby-comment"># File logger.rb, line 715</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fatal</span>(<span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">add</span>(<span class="ruby-constant">FATAL</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fatal-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fatal!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the log level to Logger::FATAL. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="fatal-21-source">
            <pre><span class="ruby-comment"># File logger.rb, line 532</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fatal!</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">FATAL</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fatal-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fatal?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the log level allows entries with severity Logger::FATAL to be written, <code>false</code> otherwise. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="fatal-3F-source">
            <pre><span class="ruby-comment"># File logger.rb, line 527</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fatal?</span>; <span class="ruby-identifier">level</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">FATAL</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-info" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">info</span><span
                                class="method-args">(progname = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to calling <a href="Logger.html#method-i-add"><code>add</code></a> with severity <code>Logger::INFO</code>.</p>

                              <div class="method-source-code" id="info-source">
            <pre><span class="ruby-comment"># File logger.rb, line 697</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">info</span>(<span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">add</span>(<span class="ruby-constant">INFO</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-info-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">info!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the log level to Logger::INFO. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="info-21-source">
            <pre><span class="ruby-comment"># File logger.rb, line 499</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">info!</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">INFO</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-info-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">info?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the log level allows entries with severity Logger::INFO to be written, <code>false</code> otherwise. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="info-3F-source">
            <pre><span class="ruby-comment"># File logger.rb, line 494</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">info?</span>; <span class="ruby-identifier">level</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">INFO</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-level" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">level</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Logging severity threshold (e.g. <code>Logger::INFO</code>).</p>

                              <div class="method-source-code" id="level-source">
            <pre><span class="ruby-comment"># File logger.rb, line 384</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">level</span>
  <span class="ruby-ivar">@level_override</span>[<span class="ruby-constant">Fiber</span>.<span class="ruby-identifier">current</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@level</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Logger.html#method-i-sev_threshold">sev_threshold</a>
                            </div>

                          </div>

                  <div id="method-i-level-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">level=</span><span
                                class="method-args">(severity)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the log level; returns <code>severity</code>. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

<p>Argument <code>severity</code> may be an integer, a string, or a symbol:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span> <span class="ruby-comment"># =&gt; 3</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-value">3</span>             <span class="ruby-comment"># =&gt; 3</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-string">&#39;error&#39;</span>       <span class="ruby-comment"># =&gt; &quot;error&quot;</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">level</span> = <span class="ruby-value">:error</span>        <span class="ruby-comment"># =&gt; :error</span>
</pre>

<p><a href="Logger.html#method-i-sev_threshold-3D"><code>Logger#sev_threshold=</code></a> is an alias for <a href="Logger.html#method-i-level-3D"><code>Logger#level=</code></a>.</p>

                              <div class="method-source-code" id="level-3D-source">
            <pre><span class="ruby-comment"># File logger.rb, line 400</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">level=</span>(<span class="ruby-identifier">severity</span>)
  <span class="ruby-ivar">@level</span> = <span class="ruby-constant">Severity</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">severity</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Logger.html#method-i-sev_threshold-3D">sev_threshold=</a>
                            </div>

                          </div>

                  <div id="method-i-log" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">log</span><span
                                class="method-args">(severity, message = nil, progname = nil)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Logger.html#method-i-add">add</a>
                            </div>
                          </div>

                  <div id="method-i-reopen" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">reopen</span><span
                                class="method-args">(logdev = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the logger’s output stream:</p>
<ul><li>
<p>If <code>logdev</code> is <code>nil</code>, reopens the current output stream.</p>
</li><li>
<p>If <code>logdev</code> is a filepath, opens the indicated file for append.</p>
</li><li>
<p>If <code>logdev</code> is an IO stream (usually <code>$stdout</code>, <code>$stderr</code>, or an open File object), opens the stream for append.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-identifier">logger</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;t.log&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;one&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">close</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;two&#39;</span>) <span class="ruby-comment"># Prints &#39;log writing failed. closed stream&#39;</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">reopen</span>
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">add</span>(<span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR</span>, <span class="ruby-string">&#39;three&#39;</span>)
<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">close</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-string">&#39;t.log&#39;</span>)
<span class="ruby-comment"># =&gt;</span>
<span class="ruby-comment"># [&quot;# Logfile created on 2022-05-12 14:21:19 -0500 by logger.rb/v1.5.0\n&quot;,</span>
<span class="ruby-comment">#  &quot;E, [2022-05-12T14:21:27.596726 #22428] ERROR -- : one\n&quot;,</span>
<span class="ruby-comment">#  &quot;E, [2022-05-12T14:23:05.847241 #22428] ERROR -- : three\n&quot;]</span>
</pre>

                              <div class="method-source-code" id="reopen-source">
            <pre><span class="ruby-comment"># File logger.rb, line 620</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">reopen</span>(<span class="ruby-identifier">logdev</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@logdev</span>&amp;.<span class="ruby-identifier">reopen</span>(<span class="ruby-identifier">logdev</span>)
  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sev_threshold" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">sev_threshold</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Logger.html#method-i-level">level</a>
                            </div>
                          </div>

                  <div id="method-i-sev_threshold-3D" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">sev_threshold=</span><span
                                class="method-args">(severity)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Logger.html#method-i-level-3D">level=</a>
                            </div>
                          </div>

                  <div id="method-i-unknown" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">unknown</span><span
                                class="method-args">(progname = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to calling <a href="Logger.html#method-i-add"><code>add</code></a> with severity <code>Logger::UNKNOWN</code>.</p>

                              <div class="method-source-code" id="unknown-source">
            <pre><span class="ruby-comment"># File logger.rb, line 721</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">unknown</span>(<span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">add</span>(<span class="ruby-constant">UNKNOWN</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-warn" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">warn</span><span
                                class="method-args">(progname = nil, &amp;block)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Equivalent to calling <a href="Logger.html#method-i-add"><code>add</code></a> with severity <code>Logger::WARN</code>.</p>

                              <div class="method-source-code" id="warn-source">
            <pre><span class="ruby-comment"># File logger.rb, line 703</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">warn</span>(<span class="ruby-identifier">progname</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
  <span class="ruby-identifier">add</span>(<span class="ruby-constant">WARN</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-warn-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">warn!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the log level to Logger::WARN. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="warn-21-source">
            <pre><span class="ruby-comment"># File logger.rb, line 510</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">warn!</span>; <span class="ruby-keyword">self</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">WARN</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-warn-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">warn?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if the log level allows entries with severity Logger::WARN to be written, <code>false</code> otherwise. See <a href="Logger.html#class-Logger-label-Log+Level">Log Level</a>.</p>

                              <div class="method-source-code" id="warn-3F-source">
            <pre><span class="ruby-comment"># File logger.rb, line 505</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">warn?</span>; <span class="ruby-identifier">level</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-constant">WARN</span>; <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-with_level" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">with_level</span><span
                                class="method-args">(severity) { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Adjust the log level during the block execution for the current Fiber only</p>

<pre class="ruby"><span class="ruby-identifier">logger</span>.<span class="ruby-identifier">with_level</span>(<span class="ruby-value">:debug</span>) <span class="ruby-keyword">do</span>
  <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> { <span class="ruby-string">&quot;Hello&quot;</span> }
<span class="ruby-keyword">end</span>
</pre>

                              <div class="method-source-code" id="with_level-source">
            <pre><span class="ruby-comment"># File logger.rb, line 409</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">with_level</span>(<span class="ruby-identifier">severity</span>)
  <span class="ruby-identifier">prev</span>, <span class="ruby-ivar">@level_override</span>[<span class="ruby-constant">Fiber</span>.<span class="ruby-identifier">current</span>] = <span class="ruby-identifier">level</span>, <span class="ruby-constant">Severity</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">severity</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">prev</span>
      <span class="ruby-ivar">@level_override</span>[<span class="ruby-constant">Fiber</span>.<span class="ruby-identifier">current</span>] = <span class="ruby-identifier">prev</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-ivar">@level_override</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Fiber</span>.<span class="ruby-identifier">current</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-format_message" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">format_message</span><span
                                class="method-args">(severity, datetime, progname, msg)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="format_message-source">
            <pre><span class="ruby-comment"># File logger.rb, line 745</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">format_message</span>(<span class="ruby-identifier">severity</span>, <span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">msg</span>)
  (<span class="ruby-ivar">@formatter</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@default_formatter</span>).<span class="ruby-identifier">call</span>(<span class="ruby-identifier">severity</span>, <span class="ruby-identifier">datetime</span>, <span class="ruby-identifier">progname</span>, <span class="ruby-identifier">msg</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-format_severity" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">format_severity</span><span
                                class="method-args">(severity)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="format_severity-source">
            <pre><span class="ruby-comment"># File logger.rb, line 741</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">format_severity</span>(<span class="ruby-identifier">severity</span>)
  <span class="ruby-constant">SEV_LABEL</span>[<span class="ruby-identifier">severity</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&#39;ANY&#39;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

